package Text5;

import java.util.*;

public class Main {
    static int N = 6010;
    static int[] f = new int[N];

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        for (int i = 1; i <= n; i++) {
            int v = in.nextInt();
            int w = in.nextInt();
            int s = in.nextInt();
            for (int j = m; j >= 1; j--) {
                for (int k = 0; k <= s && k * v <= j; k++) {
                    f[j] = Math.max(f[j], f[j - k * v] + k * w);
                }
            }
        }
        System.out.println(f[m]);
    }
}
